<template>
  <div class="box" v-if="mvBes_ !== null">
    <!-- mv的播放以及头部标题 -->
    <div class="left">
      <div class="top">
        <div class="back" @click="back"><i class="el-icon-back"></i></div>
        <div>MV详情</div>
      </div>
      <VideoPlay />
    </div>
    <div style="width:40%">
      <Right />
    </div>
    <div class="loading" v-if="show === true">
      <i class="el-icon-loading"></i>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex';
import VideoPlay from '../components/mvCom/play.vue';
import Right from '../components/mvCom/rightBar.vue';

export default {
  components: {
    VideoPlay,
    Right,
  },
  computed: {
    ...mapState(['mvBes']),
  },
  beforeRouteLeave(to, from, next) {
    this.show = true
    next()
  },
  data() {
    return {
      path: '',
      show: false,
      mvBes_: null,
    }
  },
  mounted() {
    this.mvBes_ = this.mvBes
  },
  watch: {
    mvBes(newVal, oldVal) {
      this.mvBes_ = newVal
    },
  },
  beforeRouteEnter(to, from, next) {
    next((vm) => {
      vm.path = from.fullPath
    })
  },
  methods: {
    back() {
      if (this.path === '/pageTwo/videoRec') {
        this.$router.push(
          '/pageTwo/videoRec',
        );
      } else if (this.path === '/pageTwo/mvRec') {
        this.$router.push(
          '/pageTwo/mvRec',
        );
      } else if (this.path === '/seachPage') {
        this.$router.push(
          '/seachPage',
        );
      } else {
        this.$router.push(
          `/artistsPage?id=${window.sessionStorage.getItem('artists')}`,
        );
      }
    },
  },
};
</script>

<style scoped>
.box {
  display: flex;
  margin-bottom: 40px;
}

.left {
  display: flex;
  flex-direction: column;
  width: 60%;
}

.top {
  display: flex;
  align-items: center;
  font-size: 20px;
}

.back {
  font-size: 30px;
}
</style>
